Regimes in generalized responses ================================= A generalized impulse response is the average, over many simulations, of the difference between a path with the impulse and a path without it. In RISE it is ``irf`` with ``irf_type = 'girf'``, averaged over ``irf_draws`` simulations; the other shocks are drawn and are the same on both paths of a simulation, and the constraint-enforcing shocks are not drawn. With ``irf_type`` empty (the default), ``irf`` computes a generalized response when the order of the responses is above one and ``irf_draws`` is above one; at first order, ask for ``'girf'``. In a switching model the regimes of the two paths are part of the experiment. .. contents:: :local: :depth: 2 Dates and the starting regime ------------------------------ Date 0 of the responses is the date before the impulse; with the default ``irf_shock_date = 1`` the impulse hits at date 1 (later dates: see :doc:`Surprises and announcements`). Responses that start from a regime and let the regimes move need ``irf_regime_specific = false``. The default, ``true``, computes one response per regime with that regime held in every period. ``irf_initial_conditions.regime`` is the regime at date 0. The regimes of the following dates are drawn from the transition probabilities, or set by ``simul_regime``. A starting regime with regime-specific responses is an error (``RISE:irf:startingRegimeIsRegimeSpecific``). The regime at impact --------------------- The regime of date 1 is drawn from the row of the date-0 regime of the transition matrix, evaluated at the date-0 state. The impulse enters at date 1, so it cannot move that draw: the impact regime is the same on the two paths. To fix it, give the regimes as numbers in ``simul_regime``: .. code-block:: matlab start = struct('endogenous', struct('Y', 0), 'regime', 1); out = irf(m, irf_type = 'girf', irf_draws = 2000, irf_periods = 3, ... irf_shock_sign = 100, irf_regime_specific = false, ... irf_initial_conditions = start, ... irf_girf_regime_uncertainty = true, ... simul_regime = [1, 2, NaN]); Entry 1 of ``simul_regime`` is date 0, entry 2 is date 1, and dates after the last entry take its value: ``[r0, j, NaN]`` starts in ``r0``, puts the impulse in regime ``j`` and draws the later regimes; a last entry that is a number holds that regime to the end. With a delayed impulse, ``irf_shock_date = s``, the impact regime is entry ``s+1``: ``[1, NaN, 2, NaN]`` with ``irf_shock_date = 2`` puts the impulse in regime 2, in a model solved with ``solve_shock_horizon`` of at least 1. Numbers in ``simul_regime`` hold on both paths. A first entry that differs from ``irf_initial_conditions.regime`` is an error (``RISE:irf:startingRegimeConflict``); a ``NaN`` first entry takes the starting regime from ``irf_initial_conditions``. In expectation, the response with the impact regime drawn is the average of the responses with the impact regime fixed, weighted by the probabilities of the impact regimes. The regimes of the two paths ----------------------------- ``irf_girf_regime_uncertainty`` decides how the path without the impulse gets its regimes. .. list-table:: :header-rows: 1 :widths: 18 82 * - Value - The path without the impulse * - ``false`` (default) - is given the regimes of the path with the impulse. The two paths are in the same regime at every date, and whatever the impulse does to the regime probabilities is left out of the response. * - ``true`` - takes the same uniform number as the path with the impulse at each date of the joint regime process (all the chains together). Each path turns that number into a regime through its own transition probabilities, evaluated at its own state. Under ``true`` the two paths part only where the impulse has moved the transition probabilities: a date at which the two paths draw from the same row of probabilities gives them the same regime. In a model with several chains the uniform number selects a regime of the joint process, not one regime per chain. Each path keeps its own regime law, so the expected response is that of independent regime draws, while a difference between the regimes of the two paths comes from the impulse and not from two unrelated draws. With constant transition probabilities the two paths are in the same regime at every date under ``true`` as well: ``true`` and ``false`` are the same experiment. Dates fixed by ``simul_regime`` keep their place among the uniform numbers, so fixing a date does not change the draws of the others. Under ``true`` the uniform numbers are taken by RISE's own simulation engines. A function handle in the ``simulator`` option draws its own regimes and cannot take them: it is refused (``RISE:irf:uncoupledSimulator``). Draws and units ---------------- ``irf_draws`` is the number of paired differences averaged; it does not change the shape of the output. The draws come from MATLAB's global random stream: seed it with ``rng`` before a call to repeat that call's draws. ``out.E.Y`` is a ``ts`` of the response of ``Y`` to the impulse in ``E``, with one row per date from 0 to ``irf_periods``; at date 0 both paths are at the same starting point and the response is zero. ``irf_shock_sign`` is the size of the impulse in standard deviations of the shock. In :math:`Y_t = c(s_t) + \sigma E_t` below, the impulse moves :math:`Y` by ``irf_shock_sign`` times :math:`\sigma` on impact; a loading that switches would give a different impact in each regime. Responses are in the units of the variables, and in logs for the variables declared in logs. An example that can be counted by hand --------------------------------------- The tutorial ``rise-modern-tutorials/WorkingWithAModel/girf_regimes`` uses .. math:: Y_t = c(s_t) + \sigma E_t, \qquad c(1) = 0,\; c(2) = 1, with regime 2 absorbing and a probability of entering it of 0.2 where :math:`Y` is below 0.5 and 0.8 above (a steep logistic in ``@transition_functions``). :math:`\sigma = 0.01` and the impulse is ``irf_shock_sign = 100`` standard deviations of :math:`E`, so it moves :math:`Y` by exactly one and the other draws of :math:`E` never take :math:`Y` across 0.5. The responses start in regime 1 at :math:`Y = 0`. * Date 1: both paths draw regime 2 with probability 0.2; the response is the impulse itself, 1. * Date 2: from regime 1, the path with the impulse enters regime 2 with probability 0.8 and the path without it with 0.2. The response is :math:`0.8 \times (0.8-0.2) = 0.48`. * Date 3: :math:`0.8 \times 0.6 \times 0.8 = 0.384`. With 2,000 draws (``rng(1,'twister')`` before each call), RISE returns: .. list-table:: :header-rows: 1 :widths: 46 18 18 18 * - Response of Y - Date 1 - Date 2 - Date 3 * - ``false``, copied regimes (exact: 1, 0, 0) - 1.000 - 0.000 - 0.000 * - ``true``, shared draws (exact: 1, 0.48, 0.384) - 1.000 - 0.484 - 0.373 * - ``true``, ``simul_regime = [1,1,NaN]`` (exact: 1, 0.6, 0.48) - 1.000 - 0.602 - 0.467 * - ``true``, ``simul_regime = [1,2,NaN]`` (exact: 1, 0, 0) - 1.000 - 0.000 - 0.000 The numbers are in the units of :math:`Y`. With one draw at a time, each paired difference under ``true`` is 0 or 1, never -1: where the two paths are in different regimes, the path with the impulse is the one in regime 2, because the shared uniform fell between the two entry probabilities. Weighting the two fixed-impact rows by 0.8 and 0.2 gives back the row with the impact regime drawn, up to simulation noise (0.482 and 0.374). The tutorial also runs a linear model with constant transition probabilities, :math:`Y_t = c(s_t) + 0.5\,Y_{t-1} + E_t`, on which copied regimes and shared draws give the same response, 1, 0.5 and 0.25 at dates 1 to 3.